<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>问卷广场</title>
    <link rel="stylesheet" href="/static/css/base.css">
    <link rel="stylesheet" href="/static/css/bootstrap.min.css">
    <link rel="stylesheet" href="/static/css/surveryAll.css">
    <link rel="stylesheet" href="/static/css/index.css">
</head>
<body>
    <div class="banner">
        <div class="dropdown" style="margin-left: 150px;">
            <a class="a-style" href="/surveyAll">我的问卷</a>
        </div>
    </div>
    <div class="container">
        {% for item in surveys %}
        <div id="{{item.id}}" class="survey-card shadow p-3 mb-5 bg-white rounded">
            <a href="#" onclick="getId('{{item.id}}')">
                <div class="a_lable">
                    <div>
                        <label>主题: {{item.surveyTheme}}</label>
                    </div>
                    <div>
                        <label>说明: {{item.surveyState}}</label>
                    </div>
                    
                    <div>
                        <label>创建时间: {{item.updatedTime}}</label>
                    </div>
                    <div>
                        <label>创建者: {{item.name}}</label>
                    </div>
                </div>
            </a>
            <div style="text-align: right;margin-top: 20px;">
                <img src="../static/img/人.png" alt="" style="width: 25px;"><label>{{item.usercount}}</label>
            </div>
        </div>
        {% endfor %}
    </div>

    <script src="/static/js/jquery-3.6.0.min.js"></script>
    <script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>
    <script>
         let currentId = "";
        function getId(surveyId) {
            currentId = surveyId;
            getsurvey(currentId);
        }

        function getsurvey(current) {
            axios({
                method: 'post',
                url: '/surveypage/judge',
                data: {
                    surveyId: current
                }
            }).then(function (response) {
                let res = response.data;
                console.log(res.id);
                window.location.href = `/surveypage/${res.id}`;
            }).catch((err) => {

            });
        }
    </script>
</body>
</html>